package com.wk1un2.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wk1un2.entity.ActivitySess;
import com.wk1un2.entity.Product;
import com.wk1un2.service.ActivitySessService;
import com.wk1un2.service.ProductService;
import com.wk1un2.util.Result;

/**
 * 活动场次控制器
 * 
 * @author Administrator
 *
 */
@Controller
public class ActivitySessController {
	@Autowired
	ActivitySessService service;

	@RequestMapping("/Backstage/getAllActivitySess")
	@ResponseBody
	public Object getAll(@RequestParam("page") int page, @RequestParam("limit") int limit,
			 @RequestParam("as_name") String as_name) {

		
		if (as_name == null || as_name == "") {
			as_name = null;
		}
		List<ActivitySess> ls = service.getAll((page - 1) * limit, limit, as_name);
		Result res = new Result(0, "", service.count(), ls);
		return res;
	}

//	
	@RequestMapping("/Backstage/addActivitySess")
	@ResponseBody
	public Object add(@RequestParam Map<String, Object> map) {

		System.out.println(map.get("as_name"));
		int i = service.add(map);
		Result res = new Result(0, "", i, i);
		return res;
	}

//	޸
	@RequestMapping("/Backstage/updateActivitySess")
	@ResponseBody
	public Object update(@RequestParam Map<String, Object> map) {
		System.out.println(map.get("as_name"));
		int i = service.update(map);
		Result res = new Result(0, "", i, i);
		return res;
	}

//	ɾ
	@RequestMapping("/Backstage/deleteActivitySess")
	@ResponseBody
	public Object delete(@RequestParam("as_id") int as_id) {
		System.out.println(as_id);
		int i = service.delete(as_id);
		Result res = new Result(0, "", i, i);
		return res;
	}
}